package com.quanyan.authority.web;

import com.quanyan.api.APIResponse;
import com.quanyan.authority.model.db.TbAdminUserRole;
import com.quanyan.authority.service.AdminUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Administrator on 2016/8/11.
 */
@RestController
@RequestMapping("/admin/api/authority/userRole/api/")
public class AdminUserRoleController {

    private static final Logger logger = LoggerFactory.getLogger(AdminUserRoleController.class);

    @Autowired
    private AdminUserService adminUserService;

    @RequestMapping(value = "add",method = RequestMethod.POST)
    public APIResponse add(@RequestBody List<TbAdminUserRole> tbAdminUserRole){
        try {
            adminUserService.addUserRole(tbAdminUserRole);
            return APIResponse.returnSuccess();
        } catch (Exception e) {
            logger.error("{}",e);
            return APIResponse.returnFail("系统异常！");
        }
    }

    @RequestMapping(value = "del",method = RequestMethod.POST)
    public APIResponse del(@RequestBody List<TbAdminUserRole> tbAdminUserRole){
        try {
            adminUserService.delUserRole(tbAdminUserRole);
            return APIResponse.returnSuccess();
        } catch (Exception e) {
            logger.error("{}",e);
            return APIResponse.returnFail("系统异常！");
        }
    }
}
